home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 September / macformat-028.iso / mac / Shareware City / Developers / BoxMaker++ / Typical ƒ / Typicalshell.cp < prev    next >
Encoding:
Text File  |  1995-06-14  |  2.3 KB  |  117 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <Memory.h>
  3. #include <QuickDraw.h>
  4. #include <OSUtils.h>
  5. #include <ToolUtils.h>
  6. #include <Menus.h>
  7. #include <Packages.h>
  8. #include <Traps.h>
  9. #include <Files.h>
  10. #include <Aliases.h>
  11. #include <AppleEvents.h>
  12. #include <GestaltEqu.h>
  13. #include <Processes.h>
  14. #include <Fonts.h>
  15. #include <OSEvents.h>
  16. #include <Resources.h>
  17. #include <Desk.h>
  18. #include <LowMem.h>
  19.  
  20. #include "boxmaker constants.h"
  21. #include "standardgetfile.h"
  22. #include "boxmakergetfile.h"
  23.  
  24. #include "boxmaker.h"
  25. #include "preferences.cp"
  26. #include "typicalshell.h"
  27.  
  28. #pragma template_access public
  29.  
  30. void main();
  31.  
  32. void main()
  33. {
  34.     typicalshell it;
  35.     it.run();
  36. }
  37.  
  38. const int    typicalshell::kOurQuitItem = 3;
  39. const OSType typicalshell::dontChange   = '****';
  40.  
  41. typicalshell::typicalshell() : boxmaker( 3000)
  42. {
  43.     #if NEW_HEADERS_AVAILABLE
  44.         const StringPtr appname = LMGetCurApName();
  45.     #else
  46.         //
  47.         // For some reason 'curApName' is not declared under SC++
  48.         // This doesn't bother me; I know how to find it, anyway.
  49.         // #include <LoMem.h>
  50.         // const StringPtr appname = (StringPtr)curApName;
  51.         const StringPtr appname = (StringPtr)0x910;
  52.     #endif    
  53.     if( *appname < 8)
  54.     {
  55.         SysBeep( 9);
  56.         SysBeep( 9);
  57.         SysBeep( 9);
  58.         ExitToShell();
  59.     }
  60.     #ifdef NEW_HEADERS_AVAILABLE
  61.         BlockMoveData( &appname[ 1], &typeToSet   , sizeof( typeToSet));
  62.         BlockMoveData( &appname[ 5], &creatorToSet, sizeof( creatorToSet));
  63.     #else
  64.         BlockMove( &appname[ 1], &typeToSet   , sizeof( typeToSet));
  65.         BlockMove( &appname[ 5], &creatorToSet, sizeof( creatorToSet));
  66.     #endif
  67. }
  68.  
  69. void typicalshell::OpenDoc( Boolean opening)
  70. {
  71.     if( opening)
  72.     {
  73.         if( creatorToSet != dontChange)
  74.         {
  75.             theCInfoPBRec.hFileInfo.ioFlFndrInfo.fdCreator = creatorToSet;
  76.         }
  77.         if( typeToSet != dontChange)
  78.         {
  79.             theCInfoPBRec.hFileInfo.ioFlFndrInfo.fdType = typeToSet;
  80.         }
  81.         const OSErr result = PBSetCatInfoSync( &theCInfoPBRec);
  82.         if( result != noErr)
  83.         {
  84.             SysBeep( 9);
  85.         }
  86.     }
  87. }
  88.  
  89. void typicalshell::DoMenu( long retVal)
  90. {
  91.     const short menuID = HiWord( retVal);
  92.     const short itemID = LoWord( retVal);
  93.     switch( menuID)
  94.     {
  95.         case kAppleMenuID:
  96.             DoAppleMenu( itemID);
  97.             break;
  98.             
  99.         case kFileMenuID:
  100.             switch( itemID)
  101.             {
  102.                 case kSelectFileItem:
  103.                     SelectFile();
  104.                     break;
  105.             
  106.                 case kOurQuitItem:        // NB: not kQuitItem!
  107.                     SendQuitToSelf();
  108.                     break;
  109.             }
  110.             break;
  111.         
  112.         default:
  113.             break;            
  114.     }
  115.     HiliteMenu( 0);
  116. }
  117.